//
//  XMCameraAngleCollectionViewCell.m
//  XiaoMiao
//
//  Created by Jim huang on 2018/4/22.
//  Copyright © 2018年 smallyou. All rights reserved.
//

#import "XMCameraAngleCollectionViewCell.h"
@interface XMCameraAngleCollectionViewCell ()

//外框
@property (nonatomic,strong) UIImageView * outlineImageView;
//角度文字
@property (nonatomic,strong) UILabel * titleLabel;


@end

@implementation XMCameraAngleCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUI];
    }
    return self;
}

-(void)setUI{
    
    [self.picImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self);
        make.height.equalTo(self.mas_width);
    }];
    
    [self.outlineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(self.picImageView);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.picImageView.mas_bottom);
        make.left.right.bottom.equalTo(self);
    }];
    
    [self.addImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.picImageView);
    }];
    
}

#pragma mark ----getting&setting----
//图片
-(UIImageView *)picImageView{
    if (!_picImageView) {
        _picImageView = [[UIImageView alloc]init];
        [self addSubview:_picImageView];
    }
    return _picImageView;
}

//外框
-(UIImageView *)outlineImageView{
    if (!_outlineImageView) {
        _outlineImageView = [[UIImageView alloc]init];
        [_outlineImageView setImage:kImage(@"cameraOutLine")];
        [self addSubview:_outlineImageView];
    }
    return _outlineImageView;
}
//外框
-(UIImageView *)addImageView{
    if (!_addImageView) {
        _addImageView = [[UIImageView alloc]init];
        [_addImageView setImage:kImage(@"camera_add")];
        [self addSubview:_addImageView];
    }
    return _addImageView;
}

//角度文字
-(UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.textColor = kTextBlackColor;
        _titleLabel.font = kFont(14);
        _titleLabel.text = @"正面";
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_titleLabel];
    }
    return _titleLabel;
}

-(void)setModel:(KV2CameraAngleModel *)model{
    _model = model;
    self.titleLabel.text = model.name;
    if (model.normalImage) {
        [self.picImageView setImage:model.normalImage];
    }else{
        if ([model.name isEqualToString:@"自定义"]) {
            [self.picImageView sd_setImageWithURL:[NSURL URLWithString:model.imageUrl] placeholderImage:kImage(@"photoPlaceHoder")];
        }else{
            [self.picImageView sd_setImageWithURL:[NSURL URLWithString:model.imageUrl] placeholderImage:kImage(@"ic_common_avatar_default")];
        }

    }

}



-(void)setTitleStr:(NSString *)titleStr{
    _titleStr = titleStr;
    self.titleLabel.text = titleStr;
}



-(void)dealloc{
    
    
}

@end
